package structure.proxy;

import structure.proxy.dynamic.ProxyFactory;
import structure.proxy.staticdemo.ISeller;
import structure.proxy.staticdemo.ProxyLiu;
import structure.proxy.staticdemo.ProxyLiu2;
import structure.proxy.staticdemo.SellerWang;

/**
 * Created by lie on 2017/10/31.
 * 客户类
 */
public class Client {

    public static void main(String[] args){
        staticProxyTest();
//        dynamicProxyTest();
    }

    private static void dynamicProxyTest() {
        ISeller iSeller = new SellerWang();
        ProxyFactory proxyFactory = new ProxyFactory(iSeller);
        ISeller proxyInstance = (ISeller) proxyFactory.getProxyInstance();
        proxyInstance.sell();
    }

    private static void staticProxyTest() {
        //找小刘代理
        ISeller iSeller = new SellerWang();
        ProxyLiu proxyLiu = new ProxyLiu(iSeller);
        proxyLiu.sell();

        //找小小刘代理
        ProxyLiu2 proxyLiu2 = new ProxyLiu2();
        proxyLiu2.sell();
    }
}
